import  React ,{lazy} from "react";
import { useRoutes,Navigate } from "react-router-dom";
import Login from "../views/Login/Login";
import Home from "../views/Home/Home";
import Layout from "../components/layout/index";
import Go from "../views/Go/Go";
const Room = lazy(() => import("../views/Room/Room"))
const Build = lazy(() => import("../views/Build/Build"))
const RoomList = lazy(()=> import('../views/RoomList/RoomList'))


// 独立
const frameOut = [
  {path:'/login', element:<Login/>},
  {path:'/go', element:<Go/>}
]

// 功能
const frameIn = [
    {path:'index', element:<Home/>},
    {path:'setroom',element:<Room />},
    {path:'setbuild',element:<Build />},
    { path:'roomlist',element: <RoomList /> },
    { path:'*',element:<Navigate to='/index'/>}
]


const Router = ()=>{

  let element = useRoutes([
    ...frameOut,
    {path:'/', element: <Navigate to='/index'/>},
    { path: "/*", element: <Layout /> , children: frameIn},
  ]);
  return element
}
export default Router;